//
//  DLMachineImageTC.m
//  delongzhitou
//
//  Created by Mr.Wang on 2018/11/28.
//  Copyright © 2018 delongzhitou. All rights reserved.
//

#import "DLMachineImageTC.h"
#import "DLMachineModel.h"

@interface DLMachineImageTC()

@property (nonatomic, strong) UIImageView *imgV;

@end

@implementation DLMachineImageTC

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self layoutsubControls];
        self.backgroundColor = kDLMachineTableAndCellBgColor;
//        self.backgroundColor = kColorRGB(240, 240, 240);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}
- (void) layoutsubControls {
//    UILabel *label = [UILabel new];
//    label.frame = CGRectMake(0, 0, 40, 20);
//    label.text = @"图片";
//    [self.contentView addSubview:label];
    
//    UIViewContentModeScaleToFill,
//    UIViewContentModeScaleAspectFit,
//    UIViewContentModeScaleAspectFill,
//    UIViewContentModeRedraw,
//    UIViewContentModeCenter,
//    UIViewContentModeTop,
//    UIViewContentModeBottom,
//    UIViewContentModeLeft,
//    UIViewContentModeRight,
//    UIViewContentModeTopLeft,
//    UIViewContentModeTopRight,
//    UIViewContentModeBottomLeft,
//    UIViewContentModeBottomRight,
    
    UIImageView *imgV = [UIImageView new];
    imgV.contentMode = UIViewContentModeScaleAspectFill;
    imgV.clipsToBounds = YES;
    imgV.frame = CGRectMake(kMachineNormalTCTextBgViewLeftMargin, 15, kAutoWidth(145), kMachineImageViewDefaultHeight);
    imgV.backgroundColor = kColorRGB(168, 168, 168);
    imgV.userInteractionEnabled = YES;
    [self.contentView addSubview:imgV];
    self.imgV = imgV;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imgVTap:)];
    [imgV addGestureRecognizer:tap];
}
- (void) imgVTap:(UITapGestureRecognizer *)tapGes {
    
    NSLog(@"%@", self.imageModel.resultDic[@"url"]);
    NSString *urlString = [NSString stringWithFormat:@"%@", self.imageModel.resultDic[@"url"]];
    
    DLShowImageVC *showImageVC = [DLShowImageVC new];
    showImageVC.showImgUrl = urlString;
    [kuserManager.lastVc presentViewController:showImageVC animated:YES completion:^{
        
    }];
}
- (void) setImageModel:(DLMachineModel *)imageModel {
    _imageModel = imageModel;
    
    NSString *urlString = [NSString stringWithFormat:@"%@", imageModel.resultDic[@"url"]];
    [self.imgV sd_setImageWithURL:[NSURL URLWithString:urlString]];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
